package com.ruoyi.prod.controller;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.prod.entity.po.BaseAssetType;
import com.ruoyi.prod.service.BaseAssetTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 采购管理-资产类别 前端控制器
 * </p>
 *
 * @author 强子初
 * @since 2023-02-16
 */
@Api(tags = "采购管理-资产类别")
@RestController
@RequestMapping("/base/asset-type")
public class BaseAssetTypeController {

    @Autowired
    private BaseAssetTypeService baseService;

    /**
     * 详情
     */
    @ApiOperation("详情")
    @GetMapping("/{id}")
    public R<BaseAssetType> getInfo(@PathVariable String id) {
        return R.ok(baseService.getById(id));
    }


    /**
     * 列表
     */
    @ApiOperation("列表")
    @PostMapping("/list")
    public R<List<BaseAssetType>> list(@Validated @RequestBody BaseAssetType condition) {
        return R.ok(baseService.list(condition));
    }

    /**
     * 新增
     */
    @ApiOperation("新增")
    @PostMapping("/add")
    public R<?> add(@Validated @RequestBody BaseAssetType po) {
        baseService.saveOrUpdate(po);
        return R.ok(null, "新增成功");
    }

    /**
     * 删除
     */
    @ApiOperation("删除")
    @DeleteMapping("/{id}")
    public R<?> remove(@PathVariable String id) {
        baseService.removeById(id);
        return R.ok(null, "删除成功");
    }

    /**
     * 修改
     */
    @ApiOperation("修改")
    @PutMapping("/edit")
    public R<?> edit(@Validated @RequestBody BaseAssetType po) {
        baseService.saveOrUpdate(po);
        return R.ok(null, "修改成功");
    }
}